<template>
  <div class="demo-split">
    <Split v-model="split2" mode="vertical">
      <div slot="top" class="demo-split-pane" style="margin: 20px">
        <Upload max-size="1048576"
                ref="upload"
                action="/upload/upload"
                name="excel-file"
                :show-upload-list="true"
                :on-format-error="handleFormatError"
                :on-success="handleSuccess"
                :on-error="handleError"
                :format ="['xlsx','xls']">
          <Button type="info" icon="ios-cloud-upload-outline">导入</Button>
        </Upload>

      </div>

      <div slot="bottom" class="demo-split-pane">



      </div>
    </Split>
  </div>
</template>

<script>
    export default {
        name: "ImgSave",
      data() {
        return {
          split2: 0.4,
        }
      },
      methods:{
        handleFormatError(file){
          this.$Notice.warning({
            title: '文件格式不正确',
            desc: '文件 ' + file.name + ' 格式不正确，请上传.xls,.xlsx文件。'
          })
        },
        handleSuccess(res,file){
          if(res.errcode === 0){
            this.dialoLead = false
            this.$Message.success("数据导入成功！")
            this._getBookList()
            this.$refs.upload.clearFiles()
          }
        },
        handleError(error,file){
          this.$Message.error("数据导入失败！")
        },
      }
    }
</script>

<style scoped>
  .demo-split{
    height: 40em;
    border: 1px solid #dcdee2;
    text-align: center;
    vertical-align: middle;
  }
  .demo-split-pane{
    padding: 10px;
  }
</style>
